<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" class="word" />
    <ul class="container">

    </ul>
    <script>
        let containerEle = document.querySelector(".container");
        function jsonp_0(res){
            console.log(res);
            containerEle.innerHTML = "";
            res.s.forEach(item=>{
                let liEle = document.createElement("li");
                liEle.innerHTML = item;
                containerEle.appendChild(liEle);
            })
        }
        // https://suggestion.baidu.com/su?wd=111&cb=jsonp_0
        let inpEle = document.querySelector(".word");
        inpEle.oninput = function(){
            let val = this.value;
            // console.log(val);
            if(val==""){
                containerEle.innerHTML = "";
            }else{
                let s = document.createElement("script");
                s.src = `https://suggestion.baidu.com/su?wd=${val}&cb=jsonp_0`;
             document.head.appendChild(s);   
            }
           
        }

//1. 复习 2.图片加载  方块运动  ajax  都改成  async 及await；
    </script>
</body>
</html>